
package modelo.dto.entity;

import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
public class Email {
	@Column(name="endereco_email", length=50, columnDefinition="E-mail do contato", nullable=true, unique=true)
    private String enderecoEmail;

    public Email() {
        super();
    }
    
    public Email(String enderecoEmail) {
        this();        
        this.setEnderecoEmail(enderecoEmail);
    }

    public String getEnderecoEmail() {
        return enderecoEmail;
    }

    public void setEnderecoEmail(String enderecoEmail) {
        this.enderecoEmail = enderecoEmail;
    }
    
    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((enderecoEmail == null) ? 0 : enderecoEmail.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Email other = (Email) obj;
		if (enderecoEmail == null) {
			if (other.enderecoEmail != null)
				return false;
		} else if (!enderecoEmail.equals(other.enderecoEmail))
			return false;
		return true;
	}

	@Override
    public String toString() { 
        return String.format("E-mail: %s \n", this.getEnderecoEmail());
    }
    
}
